<template>
  <div class="main-page">
    <div>姓名： <input v-model="name" type="text"></div>
    <div>年龄： <input v-model="age" type="text"></div>
    <div>身高： <input v-model="height" type="text">(米)</div>
    <div>体重： <input v-model="weight" type="text">(公斤)</div>
    <div>病史： <input v-model="history" type="text"></div>
    <div> <button @click="checked">诊断</button></div>
    <div v-show="isShow"><span>患者{{ name }}</span>的诊断结果：{{ this.ceng }}</div>

  </div>
</template>


<script>
export default {
  data() {
    return {
      name: '',
      age: 0,
      height: 0,
      weight: 0,
      history: '',
      bmi: 0,
      ceng: '',
      isShow:false
    }
  },
  methods: {
    checked() {

      this.bmi = this.weight / (this.height ^ 2)
      if (this.bmi <= 18.5) {
        this.ceng = '体重过轻'
      } else if (this.bmi > 18.5 && this.bmi <= 24.9) {
        this.ceng = '正常'
      } else if (this.bmi > 24.9 && this.bmi <= 29.9) {
        this.ceng = '体重过重'
      }
      else {
        this.ceng = '肥胖'
      }
      this.isShow = true

    }

  }
}

</script>

<style></style>
